/*
 * 版权所有(C) 晓祥工作室 2010-2020 Copyright 2010-2020 XiaoXiang Workroom. 创建日期 2011-8-19
 */
package xx.listener;

import java.sql.SQLException;
import java.util.Timer;
import java.util.TimerTask;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import xx.db.QueryRunner;
import xx.entity.manage.SystemConfig;
import xx.entity.task.NewsJob;
import xx.util.task.Task;

public class StartupListener implements ServletContextListener
{
    private static final Log log = LogFactory.getLog(StartupListener.class);

    public void contextDestroyed(ServletContextEvent event)
    {
        // TODO Auto-generated method stub
        // Task.stop();
    }

    public void contextInitialized(ServletContextEvent event)
    {
        log.info("------StartupListener start.------ ");

        log.info("当前系统是：" + SystemConfig.systemName);

        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                // NewsJob.init();
                // PageJob.init();
            }
        }, 10);

        new Timer().schedule(new TimerTask()
        {
            @Override
            public void run()
            {
                // PageJob.init();
            }
        }, 1000);

        // 执行定时器
        // Task.run();
        // 加载页面缓存
        // System.out.println("加载页面缓存");
        // PageCache.init();

        // System.out.println("StartupListener end. ");
    }
}
